<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="物业名称" prop="pmid">
        <el-select v-model="queryParams.pmid" clearable>
          <el-option
            v-for="item in carsManagement"
            :key="item.pmid"
            :label="item.propertyName"
            :value="item.pmid"
            @keyup.enter.native="handleQuery">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="费用类型" prop="ttid">
        <el-select v-model="queryParams.ttid" clearable>
          <el-option
            v-for="item in TradingType"
            :key="item.ttid"
            :label="item.typeName"
            :value="item.ttid"
            @keyup.enter.native="handleQuery">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <el-table v-loading="loading" :data="checkList">
      <el-table-column label="序号" align="center" prop="id" />
      <el-table-column label="创建时间" align="center" prop="createTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="物业名称" align="center" prop="propertyManagement.propertyName" />
      <el-table-column label="手机号" align="center" prop="tel" />
      <el-table-column label="费用类型" align="center" prop="tradingType.typeName" />
      <el-table-column label="支付渠道" align="center" prop="wixin" :formatter="wixin"/>
      <el-table-column label="支付状态" align="center" prop="zhuant" :formatter="zhuant"/>
      <el-table-column label="支付金额" align="center" prop="picete" />
      <el-table-column label="车牌号" align="center" prop="licename" />
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

  </div>
</template>

<script>
import { listCheck, getCheck, delCheck, addCheck, updateCheck } from "@/api/pxy-staff/check";
import {listManagement} from "@/api/pxy-cars/management";
import {getttApiList} from "@/api/pxy-report/paytype";

export default {
  name: "Check",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // h5消费表格数据
      checkList: [],
      carsManagement: [],
      TradingType: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        pmid: null,
        ttid: null,
      },
      // 表单参数
      form: {},
    };
  },
  created() {
    this.getList();
    this.getManagement();
    this.getgetttApiList();
  },
  methods: {
    /** 查询h5消费列表 */
    getList() {
      this.loading = true;
      listCheck(this.queryParams).then(response => {
        this.checkList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    getManagement() {
      this.loading = true;
      listManagement(this.queryParams).then(response => {
        this.carsManagement = response.rows;
        // console.log(response.rows)
        this.loading = false;
      });
    },
    getgetttApiList() {
      this.loading = true;
      getttApiList(this.queryParams).then(response => {
        this.TradingType = response.rows;
        // console.log(response.rows)
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        code: null,
        status: null,
        deleted: null,
        createTime: null,
        updateTime: null,
        pmid: null,
        tel: null,
        ttid: null,
        wixin: null,
        zhuant: null,
        picete: null,
        licename: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    wixin(row){
      return row.wixin === 0 ? '微信' : '支付宝'
    },
    zhuant(row){
      return row.zhuant === 0 ? '未完成' : '完成'
    }
  }
};
</script>
